package com.qiang.test01;

import java.io.*;
import java.util.Arrays;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class Demo04 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
       /* BufferedWriter bfw = new BufferedWriter(new FileWriter("day15\\aa.txt"));
        String s = "中国";
        bfw.write(s);
        bfw.close();
        BufferedReader bfr = new BufferedReader(new FileReader("day15\\aa.txt"));
        String s1 = bfr.readLine();
        System.out.println(s1);
        bfr.close();*/

       /* OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("day15\\aa.txt"));
        String s = "山西山西山西山西山西山西山西山西山西山西山西山西山西山西山西山西山西山西";
        osw.write(s);
        osw.close();
        InputStreamReader sr = new InputStreamReader(new FileInputStream("day15\\aa.txt"));
        char[] ch = new char[1024];
        int read;
        while ((read = sr.read(ch)) != -1) {
            System.out.println(new String(ch,0,read));
        }
        sr.close();*/

        /*FileWriter fw = new FileWriter("day15\\aa.txt");
        fw.write("中国");
        fw.close();
        FileReader fr = new FileReader("day15\\aa.txt");

        //byte[] b = new byte[1024];
        char[] ch = new char[1024];
        int read;
        while((read=fr.read(ch))!=-1){
            System.out.println(new String(ch,0,read));
        }*/

      /*  FileOutputStream f1 = new FileOutputStream("day15\\aa.txt");
        f1.write("山西".getBytes());
        f1.close();
        FileInputStream f2 = new FileInputStream("day15\\aa.txt");
        byte[] a = new byte[1024];
        int read;
        while ((read = f2.read(a)) != -1) {
            System.out.println(new String(a,0,read));
        }
        f2.close();*/

       /* String s = "中国";

//byte[] bys = s.getBytes(); //[-28, -72, -83, -27, -101, -67]
//byte[] bys = s.getBytes("UTF-8"); //[-28, -72, -83, -27, -101, -67]
        byte[] bys = s.getBytes("GBK"); //[-42, -48, -71, -6]
        System.out.println(Arrays.toString(bys));

//String ss = new String(bys);
//String ss = new String(bys,"UTF-8");
        String ss = new String(bys,"GBK");
        System.out.println(ss);*/

       /* ObjectOutputStream oo = new ObjectOutputStream(new FileOutputStream("day15\\bb.txt"));
        oo.writeObject("半山");
        oo.close();
        ObjectInputStream oo2 = new ObjectInputStream(new FileInputStream("day15\\bb.txt"));
        Object o = oo2.readObject();
        System.out.println(o);
        oo2.close();*/

        Properties pp = new Properties();
       /* FileWriter fw = new FileWriter("day15\\cc.txt");
        fw.write("张三");
        fw.write("23");
        fw.write("\r\n");
        fw.write("李四");
        fw.write("24");
        fw.close();*/

       /*pp.setProperty("张三","23");
       pp.setProperty("李四","24");
       pp.setProperty("王五","25");
       pp.setProperty("赵六","26");*/
        pp.setProperty("itheima001","佟丽娅");
        pp.setProperty("itheima002","赵丽颖");
        pp.setProperty("itheima003","刘诗诗");
        FileWriter fw = new FileWriter("day15\\cc.txt");
        pp.store(fw,"123");
        fw.close();

        FileReader fr = new FileReader("day15\\cc.txt");
        //fr.read();
        pp.load(fr);
        Set<Map.Entry<Object, Object>> entries = pp.entrySet();
        for (Map.Entry<Object, Object> entry : entries) {
            Object key = entry.getKey();
            Object value = entry.getValue();
            System.out.println(key+"=="+value);
        }


    }
}
